<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>票据管理系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
</head>

<body data-type="generalComponents">
<header class="am-topbar am-topbar-inverse admin-header">
    <div id="loginName">
        <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
            <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
                <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                    <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                        <span class="tpl-header-list-user-nick">{{userName}}</span><span
                            class="tpl-header-list-user-ico">
                    <img src="assets/img/user06.png"></span>
                    </a>
                    <ul class="am-dropdown-content">
                        <li><a href="login.html"><span class="am-icon-power-off"></span> 退出</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <style>
        .allTable {
            height: 400px;
        }

        .noData {
            background-color: #00a5fe;
            height: 300px;
            padding-left: 300px;
            padding-top: 50px;
        }

        .noDatap {
            position: absolute;
            font-family: "隶书";
            font-size: 100px;
            color: #ff0000;
            /*left: 1000px;*/
            /*top:   500px;*/
        }

        .query {
            position: relative;
            left: 800px;
            background-color: #00a6ff;
            color: white;
            width: 200px;
        }

        .ele-dot-text {
            width: 45px;
            display: inline-block;
            margin-left: 20px;
        }

        .ele-dot-status {

            width: 8px;
            height: 8px;
            display: inline-block;
            border-radius: 50%;
            line-height: 10px;
        }

        .ele-dot-status-success {
            background: #52c41a;
        }

        .ele-dot-status-error {
            background: #ff4d4f;
        }

        .ele-dot-status-info {
            background: #1890ff;
        }
    </style>
</header>

<div class="tpl-page-container tpl-page-header-fixed">
    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-table"></i>
                        <span>凭证管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu" style="display:block">
                        <li>
                            <a href="transfer-list.html" class="active">
                                <i class="am-icon-angle-right"></i>
                                <span>转让列表</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-wpforms"></i>
                        <span>我的凭证</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="my-ticket-list.html">
                                <i class="am-icon-angle-right"></i>
                                <span>我的凭证列表</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            转让列表
        </div>
        <ol class="am-breadcrumb">
            <li class="am-active"><a style="color: #999999;">凭证管理</a></li>
            <li class="am-active">转让列表</li>
        </ol>


        <!--        wawawawawawa-->

        <div class="tpl-portlet-components" class="allTable" id="transList">
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">转让编号</span>
                                </span>
                            <input type="text" class="am-form-field" placeholder="请输入凭证编号" v-model="transfer.no"
                                   style="border: 1px solid #c2cad8;width: 68%;border-radius: 3px;">
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-form-group">
                            <span style="font-size: 14px;">收单企业</span>
                            <select v-model="transfer.receiveEnterpriseId">
                                <option value="">请选择收单企业</option>
                                <option v-for="(name,index) in allEnterpriseName" :value="name.id"> {{name.name}}
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-form-group">
                            <span style="font-size: 14px;">开单企业</span>
                            <select v-model="transfer.openEnterpriseId">
                                <option value="">请选择收单企业</option>
                                <option v-for="(name,index) in allEnterpriseName" :value="name.id"> {{name.name}}
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">开单日期</span>
                                </span>
                            <input type="date" class="am-form-field" placeholder="请选择日期"
                                   style="border: 1px solid #c2cad8;width: 68%;border-radius
                                   : 3px;"
                                   v-model="transfer.openTime">
                        </div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">凭证金额</span>
                                </span>
                            <input type="number" class="am-form-field" placeholder="最低金额(万)"
                                   style="border: 1px solid #c2cad8;width: 32%;border-radius: 3px;"
                                   v-model="transfer.amount1">
                            <div class="am-form-field"
                                 style="width: 0%; border-radius: 3px;border: none;margin-left: 10px;">~
                            </div>
                            <input type="number" class="am-form-field" placeholder="最高金额(万)"
                                   style="border: 1px solid #c2cad8;width: 32%;border-radius: 3px;margin-left: 20px;"
                                   v-model="transfer.amount2">
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3">
                    </div>
                </div>
                <div class="am-g" style="margin-top: 15px;">
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm status-type">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">处理状态</span>
                                </span>
                            <div class="am-btn-group am-btn-group-sm">
                                <button type="button" class="am-btn am-btn-primary am-radius" @click="all">全部</button>
                                <button type="button" class="am-btn am-btn-default" @click="success">成功</button>
                                <button type="button" class="am-btn am-btn-default" @click="ing">转让中</button>
                                <button type="button" class="am-btn am-btn-default" @click="failed">失败</button>
                            </div>
                        </div>
                    </div>
                    <input type="submit" class="query am-btn am-btn-default " id="query" value="查询" @click="query">

                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-title">转让编号</th>
                            <th class="table-author am-hide-sm-only">转让金额（元）</th>
                            <th class="table-date am-hide-sm-only">开单企业</th>
                            <th class="table-date am-hide-sm-only">收单企业</th>
                            <th class="table-date am-hide-sm-only">金融机构</th>
                            <th class="table-date am-hide-sm-only">开单日期</th>
                            <th class="table-date am-hide-sm-only">转单日期</th>
                            <th class="table-date am-hide-sm-only">到期日期</th>
                            <th class="table-date am-hide-sm-only">上链地址</th>
                            <th class="table-date am-hide-sm-only">处理状态</th>
                            <th class="table-date am-hide-sm-only">进度状态</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody id="doc-modal-list">
                        <tr v-for="(record,index)  in page.data">
                            <td class="am-hide-sm-only">{{record.no}}</td>
                            <td class="am-hide-sm-only">{{record.amount|numFilter}}</td>
                            <td class="am-hide-sm-only">{{record.openEnterpriseName}}</td>
                            <td class="am-hide-sm-only">{{record.receiveEnterpriseName}}</td>
                            <td class="am-hide-sm-only">{{record.institutyName}}</td>
                            <td class="am-hide-sm-only">{{record.openTime}}</td>
                            <td class="am-hide-sm-only">{{record.transferTime}}</td>
                            <td class="am-hide-sm-only">{{record.expiryTime}}</td>
                            <td class="am-hide-sm-only">{{record.uplinkAddress}}</td>
                            <td class="am-hide-sm-only">{{record.status}}</td>
                            <td class="am-hide-sm-only">{{record.progressStatus}}</td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a href="#" @click.prevent="listTicketDetail(record.id)"><span
                                                class="am-text-secondary"
                                                style="cursor:pointer"><span></span>详情</span></a>
                                    </div>
                                </div>
                            </td>
                        </tr>


                        </tbody>
                    </table>
                    <div class="am-cf">
                        <div v-if="page.total == 0" class="noData">
                            <p class="noDatap"> 没有查询到相关数据！</p>
                        </div>

                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">
                                <li>
                                    <a href="#" @click.prevent="toPage(page.currentPage - 1)"> « </a></li>
                                <li>
                                    <a href="#" @click.prevent="toPage(page.currentPage-2)"
                                       v-if="page.currentPage -2 > 0">{{page.currentPage - 2}}</a></li>
                                <li><a href="#" @click.prevent="toPage(page.currentPage-1)"
                                       v-if="page.currentPage -1 > 0">{{page.currentPage - 1}}</a></li>
                                <li class="am-active"><a href="#"
                                                         @click.prevent="toPage(page.currentPage+0)">{{page.currentPage}}</a>
                                </li>
                                <li><a href="#" @click.prevent="toPage(page.currentPage+1)"
                                       v-if="page.currentPage +1 <= page.lastPage">{{page.currentPage + 1}}</a></li>
                                <li><a href="#" @click.prevent="toPage(page.currentPage +2)"
                                       v-if="page.currentPage +2 <= page.lastPage">{{page.currentPage + 2}}</a></li>
                                <li><a href="#" @click.prevent="toPage(page.currentPage + 1) ">»</a></li>
                            </ul>
                        </div>
                    </div>
                    <hr>
                </div>
            </div>
        </div>


    </div>
</div>
<script src="assets/js/vue.js"></script>
<script src="assets/js/axios.min.js"></script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script>
    const query = new Vue({
        el: "#transList",
        data: {
            transfer: {
                no: '',
                receiveEnterpriseId: '',
                openEnterpriseId: '',
                openTime: '',
                amount1: '',
                amount2: '',
                progressStatus: '',
            },
            page: {},
            allEnterpriseName: {
                id: '',
                name: ''
            },
            enterpriseId: '',
            userName: "",
            loginEnterprise:"",
        },
        methods: {
            toPage(pageNum) {
                let _this = this;
                if (pageNum == 0) {
                    pageNum = 1;
                }
                if (pageNum >= this.lastPage) {
                    pageNum = this.lastPage;
                }
                let enterpriseId = JSON.parse(window.sessionStorage.getItem("loginEnterpriseId"));
                axios.post("admin/query.trans?currentPage=" + pageNum + "&" + "enterpriseId=" + enterpriseId, this.transfer).then(response => {
                    if (response.data.value.data.length != 0) {
                        _this.page = response.data.value;
                    }
                    //状态转义
                    for (let i = 0; i < this.page.data.length; i++) {
                        if (_this.page.data[i].status === "A") {
                            _this.page.data[i].status = "成功"
                        } else if (_this.page.data[i].status === "B") {
                            _this.page.data[i].status = "转让中"
                        } else if (_this.page.data[i].status === "C") {
                            _this.page.data[i].status = "失败"
                        }
                    }
                    for (let i = 0; i < this.page.data.length; i++) {
                        if (_this.page.data[i].progressStatus === "A") {
                            _this.page.data[i].progressStatus = "已签收"
                        } else if (_this.page.data[i].progressStatus === "B") {
                            _this.page.data[i].progressStatus = "未签收"
                        } else if (_this.page.data[i].progressStatus === "C") {
                            _this.page.data[i].progressStatus = "失败"
                        }
                    }
                })
            }
            ,
            query() {
                let _this = this;
                this.loginEnterprise = JSON.parse(window.sessionStorage.getItem("loginEnterpriseId"));
                axios.post('admin/query.trans?enterpriseId=' + this.loginEnterprise, this.transfer).then(response => {
                    let data = response.data
                    _this.page = data.value;
                    //状态转义
                    for (let i = 0; i < this.page.data.length; i++) {
                        if (_this.page.data[i].status === "A") {
                            _this.page.data[i].status = "成功"
                        } else if (_this.page.data[i].status === "B") {
                            _this.page.data[i].status = "转让中"
                        } else if (_this.page.data[i].status === "C") {
                            _this.page.data[i].status = "失败"
                        }
                    }
                    for (let i = 0; i < this.page.data.length; i++) {
                        if (_this.page.data[i].progressStatus === "A") {
                            _this.page.data[i].progressStatus = "已签收"
                        } else if (_this.page.data[i].progressStatus === "B") {
                            _this.page.data[i].progressStatus = "未签收"
                        } else if (_this.page.data[i].progressStatus === "C") {
                            _this.page.data[i].progressStatus = "失败"
                        }
                    }
                })
            },
            all() {
                this.transfer.Status = ""
            },
            success() {
                this.transfer.Status = "A"
            },
            ing() {
                this.transfer.Status = "B"
            },
            failed() {
                this.transfer.Status = "C"
            },
            listTicketDetail(detailId) {
                location.href = "transfer-detail.html?id=" + detailId
            }
        },

        created() {
            let _this = this;
            let enterpriseId = JSON.parse(window.sessionStorage.getItem("loginEnterpriseId"));
            _this.userName = JSON.parse(window.sessionStorage.getItem("userName"));
            console.log("登录id:" + enterpriseId)
            if (enterpriseId === null) {
                location.href = "login.html";
            }
            axios.post('admin/dropDown1.trans').then(response => {
                let data = response.data;
                _this.allEnterpriseName = data.value;
            })
            axios.post('admin/query.trans?enterpriseId=' + enterpriseId, this.transfer).then(response => {
                    let data = response.data;
                    _this.page = data.value;
                    //状态转义
                    for (let i = 0; i < this.page.data.length; i++) {
                        if (_this.page.data[i].status === "A") {
                            _this.page.data[i].status = "成功"
                        } else if (_this.page.data[i].status === "B") {
                            _this.page.data[i].status = "转让中"
                        } else if (_this.page.data[i].status === "C") {
                            _this.page.data[i].status = "失败"
                        }
                    }
                    for (let i = 0; i < this.page.data.length; i++) {
                        if (_this.page.data[i].progressStatus === "A") {
                            _this.page.data[i].progressStatus = "已签收"
                        } else if (_this.page.data[i].progressStatus === "B") {
                            _this.page.data[i].progressStatus = "未签收"
                        } else if (_this.page.data[i].progressStatus === "C") {
                            _this.page.data[i].progressStatus = "失败"
                        }
                    }
                }
            )
        },
        filters: {
            numFilter: function (value) {
                return parseFloat(value).toFixed(2);
            }
        }
    })
    const name2 = new Vue({
        el: "#loginName",
        data: {
            userName: "",
        },
        created() {
            this.userName = query.userName;
        }
    })
</script>
<script>
    // 提交按钮
    $(function () {
        //状态按钮样式切换
        $('.status-type').find('button').on('click', function () {
            let statusTypeBtnArr = $('.status-type').find('button');
            for (let i = 0; i < statusTypeBtnArr.length; i++) {
                statusTypeBtnArr.eq(i).removeClass('am-btn-primary');
            }
            $(this).addClass('am-btn-primary');
        });
    });
</script>
</body>

</html>